﻿using UnityEngine;
using System.Collections;


public class PlayerControllerState{
    /// is the character colliding right ?
    public bool IsCollidingRight { get; set; }
    /// is the character colliding left ?
    public bool IsCollidingLeft { get; set; }
    /// is the character colliding with something above it ?
    public bool IsCollidingAbove { get; set; }
    /// is the character colliding with something above it ?
    public bool IsCollidingBelow { get; set; }
    /// is the character colliding with anything ?
    public bool HasCollisions { get { return IsCollidingRight || IsCollidingLeft || IsCollidingAbove || IsCollidingBelow; } }

    /// returns the slope the character is moving on angle
    public float SlopeAngle { get; set; }
    /// returns true if the slope angle is ok to walk on
    public bool SlopeAngleOK { get; set; }
    /// returns true if the character is standing on a moving platform
    public bool OnAMovingPlatform { get; set; }

    /// Is the character grounded ? 
    public bool IsGrounded { get { return IsCollidingBelow; } }
    /// is the character falling right now ?
    public bool IsFalling { get; set; }
    /// was the character grounded last frame ?
    public bool WasGroundedLastFrame { get; set; }
    /// was the character grounded last frame ?
    public bool WasTouchingTheCeilingLastFrame { get; set; }
    /// did the character just become grounded ?
    public bool JustGotGrounded { get; set; }

    public bool IsDashing { get; set; }

    public bool StayInAir { get; set; }
    /// <summary>
    /// Reset all collision states to false
    /// </summary>
    public virtual void Reset()
    {
        IsCollidingLeft =
        IsCollidingRight =
        IsCollidingAbove =
        IsCollidingBelow =
        SlopeAngleOK =
        JustGotGrounded = false;
        IsFalling = true;
        SlopeAngle = 0;
    }

    public void init()
    {
        IsCollidingLeft =
        IsCollidingRight =
        IsCollidingAbove =
        IsCollidingBelow =
        SlopeAngleOK =
        IsDashing =
        StayInAir = 
        JustGotGrounded = false;
        IsFalling = true;
        SlopeAngle = 0;
    }

    /// <summary>
    /// Serializes the collision states
    /// </summary>
    /// <returns>A <see cref="System.String"/> that represents the current collision states.</returns>
    public override string ToString()
    {
        return string.Format("(controller: r:{0} l:{1} a:{2} b:{3} down-slope:{4} up-slope:{5} angle: {6}",
        IsCollidingRight,
        IsCollidingLeft,
        IsCollidingAbove,
        IsCollidingBelow,
        SlopeAngle);
    }
}
